/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.dusin.util;

import com.google.gson.Gson;
import java.util.HashMap;
import java.util.Map;


/**
 *
 * @author dusin
 */
public class TheUtil {

    
    public static String getJsonResult(boolean success,String msg){
        Gson gson = new Gson();
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("status", success);
        map.put("msg", msg);
        return gson.toJson(map);        
    }
    //截取文件后缀名，扩展名
    public static String fileSuffix(String filename){        
        return filename.substring(filename.lastIndexOf(".") + 1);
    }
    //将所有参数连接起来
    public static String concatParams(Object... params){
        StringBuilder sb = new StringBuilder();
        for(Object o:params){
            sb.append(o).append(",");
        }
        if(sb.charAt(sb.length()-1)==','){
            sb.deleteCharAt(sb.length()-1);
        }
        return sb.toString();
    }
}
